{extend name="Public/base" /}
{block name="main"}
    <fieldset class="layui-elem-field">
        <legend>客户管理 - 新增客户</legend>
        <div class="layui-field-box">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span>登录名</label>
                    <div class="layui-input-block">
                        <input type="text" name="user_name" required value="{:isset($detail['user_name'])?$detail['user_name']:''}" lay-verify="required" placeholder="请输入账号名" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span>登录密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="password" required value="{:isset($detail['password'])?$detail['password']:''}" placeholder="请输入密码" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span> 真实姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="nickname" required value="{:isset($detail['nickname'])?$detail['nickname']:''}" lay-verify="required" placeholder="请输入真实姓名" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="admin-form">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
{/block}
{block name="myScript"}
        <script>
            layui.use('form', function(){
                var form = layui.form();
                form.on('submit(admin-form)', function(data){
                    {if condition='!empty($detail.user_name)'}
                        data.field.oldname = "{$detail.user_name}";
                    {/if}
                    $.ajax({
                        type: "POST",
                        url: '{:U("addOne")}',
                        data: data.field,
                        success: function(msg){
                            if( msg.code == 1 ){
                               parent.location.reload();
                            }else{
                                parent.layer.msg(msg.msg, {
                                    icon: 5,
                                    shade: [0.6, '#393D49'],
                                    time:1500
                                });
                            }
                        }
                    });
                    return false;
                });

            });
        </script>
   
{/block}